package me.sealer.java8.actparamterized.utils;


import me.sealer.java8.actparamterized.model.Apple;
import me.sealer.java8.actparamterized.predicate.ApplePredicate;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by sealer on 09-17-2017.
 */
public class AppleUtil {

    /**
     * 根据传入的谓词进行不同的操作
     */
    public static List<Apple> filterGreenApples(List<Apple> inventory, ApplePredicate predicate) {
        List<Apple> result = new ArrayList<>();
        for (Apple apple : inventory) {
            if (predicate.test(apple)) {
                result.add(apple);
            }
        }
        return result;
    }

}
